﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Collections;
using System.Drawing;

namespace Pharmacy_management_system
{
    class publicclass
    {
        public static string fhz;

        public static void panduan(CheckBox a, CheckBox b)
        ///复选按钮使用单选功能
        {
            if (a.Checked)
            {
                b.Checked = false;
            }
        }
        public static void xuanze(CheckBox a, DateTimePicker b, DateTimePicker c, CheckBox d, CheckBox e, Boolean f)
        {
            if (a.Checked)
            {
                b.Enabled = f;
                c.Enabled = f;
                d.Enabled = f;
                e.Enabled = f;
            }
        }
        public static void zxsqlyj(string sqlyj, string sqllj)
        {
            SqlConnection con1 = new SqlConnection(sqllj);
            con1.Open();
            SqlCommand cmd1 = new SqlCommand(sqlyj, con1);
            cmd1.ExecuteScalar();
            con1.Close();
            return;
        }
        public static ArrayList yy(string a, ArrayList b)
        {
            if (a == "" || a == null)
            {
                b.Clear();
            }
            else
            {
                string[] val;
                val = a.Split('-');
                foreach (string i in val)
                {
                    b.Add(i);
                }
            }
            return b;
        }
        //判断TabPage  b是否在TabControl  a中，如果不在，添加进去
        public void tabpageadd(TabControl a, TabPage b)
        {
            bool dand = true;
            foreach (TabPage k in a.TabPages)
            {
                if (k.Name == b.Name)
                    dand = false;
            }
            if (dand)
            {
                a.TabPages.Add(b);
            }
            a.SelectedTab = b;
        }
        //清空界面
        public void Emptycondition(string[] a, RichTextBox[] b, CheckBox[] c)
        {
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = "";
            }
            for (int i = 0; i < b.Length; i++)
            {
                b[i].Text = "";
            }
            for (int i = 0; i < c.Length; i++)
            {
                c[i].Checked = false;
            }
        }
        //将部分控件隐藏起来
        //panel a  参照的控件  panel b  移动的控件  int c  =1左对齐=2右对齐
        public void yincangkj(Panel a, Panel b,int c)
        {
            if (c == 1)
            {
                Point a1 = new Point();
            a1.X = a.Location.X;
            a1.Y = a.Location.Y+a.Size.Height+3;
            b.Location = a1;
            }
            else if (c == 2)
            {
                Point a1 = new Point();
                a1.X = a.Location.X+a.Size.Width-b.Size.Width;
                a1.Y = a.Location.Y + a.Size.Height + 3;
                b.Location = a1;
            }
            
        }
        //public void zhankaikj(Panel a, Panel b, int c)
        //{
        //    if (c == 1)
        //    {
        //        Point a1 = new Point();
        //        a1.X = a.Location.X;
        //        a1.Y = a.Location.Y - a.Size.Height - 3;
        //        b.Location = a1;
        //    }
        //}
    }

}
